import 'package:flutter/material.dart';

void showLockInfoDialog2({
  required BuildContext context,
  String title = '提示',
  required Widget content,
  String cancelText = '取消',
  VoidCallback? onCancel,
  String confirmText = '确定',
  VoidCallback? onConfirm,
  double? width,
  double? height,
}) {
  showDialog(
    context: context,
    barrierDismissible: false,
    builder: (context) {
      return Dialog(
        backgroundColor: Colors.white,
        shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
        insetPadding: const EdgeInsets.symmetric(horizontal: 40),
        child: SizedBox(
          width: width,
          height: height,
          child: Column(
            mainAxisSize: height == null ? MainAxisSize.min : MainAxisSize.max,
            children: [
              // 标题
              Padding(
                padding: const EdgeInsets.only(top: 20),
                child: Text(
                  title,
                  style: const TextStyle(
                    fontSize: 16,
                    fontWeight: FontWeight.bold,
                    color: Colors.black,
                  ),
                ),
              ),
              const SizedBox(height: 16),

              // 内容
              Padding(
                padding: const EdgeInsets.symmetric(horizontal: 20),
                child: content,
              ),

              const SizedBox(height: 20),
              const Divider(height: 1),

              // 按钮区
              SizedBox(
                height: 48,
                child: Row(
                  children: [
                    // 取消按钮
                    Expanded(
                      child: GestureDetector(
                        onTap: () {
                          Navigator.pop(context);
                          if (onCancel != null) onCancel();
                        },
                        child: Center(
                          child: Text(
                            cancelText,
                            style: const TextStyle(
                              color: Colors.black87,
                              fontSize: 14,
                            ),
                          ),
                        ),
                      ),
                    ),

                    // 分割线
                    Container(width: 1, height: 50, color: Color(0xFFD1D3D5)),

                    // 确定按钮
                    Expanded(
                      child: GestureDetector(
                        onTap: () {
                          Navigator.pop(context);
                          if (onConfirm != null) onConfirm();
                        },
                        child: Center(
                          child: Text(
                            confirmText,
                            style: const TextStyle(
                              color: Colors.red,
                              fontWeight: FontWeight.bold,
                              fontSize: 14,
                            ),
                          ),
                        ),
                      ),
                    ),
                  ],
                ),
              ),
            ],
          ),
        ),
      );
    },
  );
}
